require("./index.css");
var _mm=require("util/mm.js");
var naviTpl=require('./index.tpl');

var globalNavi={
	option : {
        name : 'home',
        navList : [
       		{name : 'home', desc : '首页', href: './index.html'},
       		{name : 'login', desc : '登录', href: './login.html'},
            {name : 'user-center', desc : '个人中心', href: './user-center.html'},
            {name : 'order-list', desc : '我的订单', href: './order-list.html'},
            {name : 'user-pass-update', desc : '修改密码', href: './user-pass-update.html'},
            {name : 'about', desc : '关于MMall', href: './about.html'}
        ]
    },
    setHtml:function(optionName){
    	var _this=this;
    	var options=$.extend(_this.option,optionName);
    	
    	var navList=options.navList;
    	for(var i=0; i < navList.length ; i++){
    		if(options.name==navList[i].name){
    			navList[i].state="active";
    		}else{
                navList[i].state="";
            }
    	}

        var naviHtml=naviTpl({
            name:options.name,
            naviList:navList
        });

    	// var html="";
    	// $.each(options.navList,function(i,item){
    	// 	html+='<li  class="'+(item.state || "")+'"><a name="'+item.name+'" href="'+item.href+'">'+item.desc+'</a></li>';
    	// });


    	$('#globalNavi-panel').html(naviHtml);
    },
}

module.exports=globalNavi;